package com.zslin.basic.tools;

import com.zslin.basic.dto.LoginUserDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 检查是否有权限访问Api接口
 */
@Component
public class AuthCheckTools {

//    Logger log = LoggerFactory.getLogger(AuthCheckTools.class);

    @Autowired
    private AuthTokenTools authTokenTools;

    public boolean hasAuth(String token) {
        LoginUserDto user = authTokenTools.parseToken(token);
//        log.info("当前登陆用户是："+user);
        if(user==null) {return false;}
        authTokenTools.refreshToken(token); //每次请求之后都需要刷新权限，这样才能保证权限不过期
        return true; //TODO 现在默认都有权限访问
    }
}
